<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:mcv="http://myfaces.apache.org/commons/validators">

<h:head></h:head>

<h:body>
	<ui:composition>
		<p:dialog id="edit_user_dialog" header="Change user account" widgetVar="editUserDialog"
			modal="true" draggable="false" resizable="false" dynamic="true" closable="false">
	    <p:ajax event="close" update="edit_user_dialog" />
	    <h:form id="edit_form">

		<p:messages id="errors" for="" showDetail="false" showSummary="true" autoUpdate="true"
			closable="false" />
        		
        	<h:panelGrid id="editUserGrid" columns="2" style="margin-bottom:10px" cellpadding="5">
        		<p:outputLabel for="editUsername" value="Name:" />
				<p:inputText id="editUsername" value="#{usersBean.user.name}" />
					
				<p:outputLabel for="editUserLogin" value="Login:"/>
				<p:inputText id="editUserLogin" value="#{usersBean.user.login}"
					required="true"	readonly="true"
					requiredMessage="Login is required!" />
						
				<p:outputLabel for="editUserEmail" value="E-mail:" />
				<p:inputText id="editUserEmail" value="#{usersBean.user.email}"
					validator="#{userBean.validateEmail}"
					autocomplete="false">
				</p:inputText>
					
				<p:outputLabel for="editUserIsAdmin" value="Admin:" />
        		<p:selectBooleanCheckbox id="editUserIsAdmin" value="#{usersBean.admin}" >
        			<p:ajax update="lblEditUserURL, editUserURL" />
        		</p:selectBooleanCheckbox>	
        		
        		<p:outputLabel id="lblEditUserURL" for="editUserURL" value="JIRA Server URL:"/>
				<p:inputText id="editUserURL" value="#{usersBean.url}"
					required="#{!usersBean.admin}" requiredMessage="URL is required."
					readonly="#{usersBean.admin}">
					<mcv:validateUrl />
				</p:inputText>
			
				<p:outputLabel for="editUserPwd1" value="Password:" />
        		<p:password id="editUserPwd1" match="editUserPwd2" value="#{usersBean.user.password}" 
   					required="true" requiredMessage="Password is required."
   					validator="#{usersBean.validatePassword}" />
 					
 				<p:outputLabel for="editUserPwd2" value="Password confirmation:" />
        		<p:password id="editUserPwd2" value="#{usersBean.user.password}"
        			requiredMessage="Password must be confirmed."
        			required="true"/>							
					
				<p:commandButton value="Apply" actionListener="#{usersBean.saveUser}"
					update="editUserGrid, :user_form:usersTable, :user_form:growl" icon="ui-icon-check"
					oncomplete="if (args &amp;&amp; !args.validationFailed) editUserDialog.hide()"
					onstart="statusDialogForEdit.show();" onsuccess="statusDialogForEdit.hide();" />
				<p:commandButton value="Cancel" actionListener="#{usersBean.cancelHandle}"
					immediate="true" icon="ui-icon-close" >
				</p:commandButton>   			
			</h:panelGrid>
		</h:form>
		</p:dialog>
		
		<p:dialog id="loadStatusForEdit" widgetVar="statusDialogForEdit" modal="true" draggable="false" closable="false" 
			resizable="false" showHeader="false"  style="background-color: transparent; box-shadow: none; border: none;"  >
				<p:graphicImage  value="/resources/img/loading.gif" />	
		</p:dialog>	
	</ui:composition>
</h:body>
</html>